(function(angular){
    "user strict";
    //创建当前正在热映的模块
    var module= angular.module('moviecat.in_theaters', ['ngRoute',"moviecat.services.http"]);
    var message=document.getElementById("message");

    module.controller('in_theaterCon', ["$scope","HttpServices","$routeParams",function($scope,HttpServices,$routeParams) {
        console.log($routeParams);
        $scope.type=$routeParams.type;
        var url="http://api.douban.com/v2/movie/"+$routeParams.type;
        $scope.keyword=$routeParams.keyword;
        console.log($scope.keyword);
        if ($scope.type === 'search') {
            url="http://api.douban.com/v2/movie/"+$routeParams.type+'?q=' +$scope.keyword+"&";
        }
        console.log(url);
        $scope.loading=true;
        HttpServices.jsonp(url,{
       count:6,
       start:$routeParams.page
   },function (data){
       $scope.loading=false;
       $scope.datas=data.subjects;
       $scope.totalCount=data.total;
       var pagecount=data.total/6;
       var page=[];
        for(var j=0;j<pagecount;j++){
                page.push(j+1);
          }
       $scope.page=page;

       $scope.$apply("datas");
   })
      }]);
})(angular)